package javagamecontroller.components.joystick;

import android.graphics.Paint;
import util.input.android.events.LineSegment;


/**
 * A class to allow touch events to show up on the screen.
 * 
 * @author Ben Schwab
 * 
 */
public class PaintSegment extends LineSegment {
    
    private static final int START_ALPHA = 255;
    private Paint myPaint;
    private int myAlpha;
    private int myFrames;
    private int myCurFrames;

    public PaintSegment (int startX, int startY, int endX, int endY, int parentWidth,
                         int parentHeight, int duration, int fps, Paint startPaint) {
        super(startX, startY, endX, endY, parentWidth, parentHeight);
        myAlpha = START_ALPHA;
        myFrames = duration * fps;
        myCurFrames = 0;
        myPaint = startPaint;

    }

    public Paint getPaint () {
        return myPaint;
    }

    public boolean incrementScreenDuration () {
        myCurFrames++;
        myAlpha = (int) (START_ALPHA - START_ALPHA * ((double) myCurFrames / myFrames));
        myPaint.setAlpha(myAlpha);
        if (myCurFrames >= myFrames) { return true; }
        return false;
    }

}
